import { Vue } from 'vue-property-decorator'
const files: any = require.context('./', true, /\.vue$/)
const components: any = {}

files.keys().forEach((key: string) => {
  try {
    const str = key.match(/[^\/]+$/)![0].replace(/\.vue$/, '')
    if (files(key).default.extendOptions.data().isCommon) {
      components[str] = files(key).default
    }
  } catch { }
})

Object.keys(components).forEach((key: string) => {
  Vue.component(key, components[key])
})
